package com.cloud.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;

@Configuration
// 仅需配置单个时，使用LoadBalancerClient即可
//@LoadBalancerClient(name = "say-hello", configuration = HelloConfig.class)
// 可配置多个LoadBalancerClient
@LoadBalancerClients({@LoadBalancerClient(name = "say-hello", configuration = HelloConfig.class)
        , @LoadBalancerClient(name = "say-goodbye", configuration = GoodbyeConfig.class)})
public class WebClientConfig {

    @LoadBalanced
    @Bean
    WebClient.Builder webClientBuilder() {
        return WebClient.builder();
    }
}
